Keep priced Cursor days when some events omit totalCents - #3005
Conversation
A missing totalCents on one usage event no longer voids that day's priced siblings or the rest of the 30-day window. Co-authored-by: Cursor <cursoragent@cursor.com>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0425dde33b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| var hasPartialCost: Bool { | ||
| let values = self.providers.map(\.totalCost) | ||
| return values.contains { $0 != nil } && values.contains { $0 == nil } |
There was a problem hiding this comment.
Mark retained Cursor subtotals as partial
When a Cursor subscription contains both priced and unpriced events, its retained subtotal is non-nil, so a group containing only that subscription makes this predicate return false. The dashboard consequently renders the lower-bound subtotal without the new ~ prefix or “Partial estimate” caption, and shared currency totals are likewise marked complete. Track partiality within each provider, not only the presence of an entirely unpriced provider.
Useful? React with 👍 / 👎.
| dailyPoints: dailyPoints, | ||
| totalTokens: Self.completeIntSum(providers.map(\.totalTokens)), | ||
| totalCost: Self.completeCostSum(providers.map(\.totalCost)), | ||
| totalTokens: Self.knownIntSum(providers.map(\.totalTokens)), |
There was a problem hiding this comment.
Label partial token totals before exposing known-only sums
When one same-currency provider has invalid or unavailable token history and a peer has a valid count, this now produces only the known lower bound. Although hasPartialTokens is computed, neither the dashboard's “Tracked tokens” value nor the share card/text uses it, so both present that lower bound as an exact total. Keep the aggregate unavailable or propagate token partiality into every renderer before returning the known-only sum.
Useful? React with 👍 / 👎.
| static func checkedKnownCostSum(_ lhsUSD: Double?, _ rhsCents: Double?) -> Double? { | ||
| guard let rhsCents else { return lhsUSD } | ||
| guard rhsCents >= 0 else { return nil } | ||
| let sum = (lhsUSD ?? 0) + rhsCents / 100.0 | ||
| return sum.isFinite ? sum : nil |
There was a problem hiding this comment.
Preserve invalid cost state across later Cursor events
If an event has a negative totalCents, or a prior addition overflows, this helper returns nil; a subsequent priced event then treats that same nil as an empty accumulator via lhsUSD ?? 0 and publishes only the later cost. Thus malformed input can produce an order-dependent, apparently valid subtotal instead of failing closed. Distinguish “no priced event yet” from an accumulator invalidated by bad data or overflow.
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. Reviewed August 17, 2026, 10:18 AM ET / 14:18 UTC. ClawSweeper reviewWhat this changesThe PR preserves known Cursor costs when sibling events omit Merge readiness⛔ Blocked until stronger real behavior proof is added - 5 items remain Keep open: malformed Cursor prices can still be mistaken for intentionally omitted prices when they occur in a different model, so the dashboard may publish a lower-bound cost despite the PR’s fail-closed intent. The supplied screenshot also does not show the requested Cursor mixed-event behavior after the fix. Priority: P2 Review scores
Verification
How this fits togetherCodexBar aggregates Cursor usage events into per-model and per-day cost reports, then validates those reports before showing spend totals in Usage & Spend. The new Cursor logic affects whether a daily cost becomes an available or partial dashboard value. flowchart LR
A[Cursor usage events] --> B[Per-model aggregation]
B --> C[Daily report]
C --> D[Dashboard history validation]
D --> E[Usage and Spend totals]
Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Carry invalid Cursor-price provenance through daily and summary aggregation, add a mixed-model regression, then provide redacted after-fix runtime evidence for a Cursor history containing both priced and omitted events. Do we have a high-confidence way to reproduce the issue? Yes, source establishes a deterministic fixture: put negative or non-finite cents in one Cursor model and a valid price in another on the same day; the reducer retains the valid model’s day total. Is this the best way to solve the issue? No; the same-model latch is correct, but invalidity must also survive the cross-model day and summary reductions before omitted prices may be retained. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c628822bae90. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
After-fix proofDid not dump live Cursor usage events (cookie/keychain). The dashboard failure mode was: one event missing Focused tests on
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
A negative totalCents now latches the accumulator closed so a later priced sibling cannot restore a lower-bound dollar total. Co-authored-by: Cursor <cursoragent@cursor.com>
After-fix proof
Focused: Live Cursor cookies were not read. Dashboard partial-group presentation is on the #3001/#3009 stack: @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6395d05b6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| cacheCreationTokens = ModelAccumulator.checkedSum([cacheCreationTokens, accumulator.cacheCreationTokens]) | ||
| requestCount = ModelAccumulator.checkedSum([requestCount, accumulator.requestCount]) | ||
| costUSD = Self.checkedUSDTotal(costUSD, accumulator.costUSD) | ||
| costUSD = Self.checkedKnownUSDTotal(costUSD, accumulator.costUSD) |
There was a problem hiding this comment.
Preserve invalidity when combining Cursor model costs
When one model on a day contains a negative/nonfinite totalCents and another model has a valid price, costInvalid makes the first accumulator's cost nil, but this reducer treats that nil exactly like an intentionally unpriced model and publishes the valid model's subtotal. The dashboard can then accept the malformed model as an allowed omitted-price row and present an apparently valid lower bound. Fresh evidence beyond the prior same-model issue is that later events now remain invalid, but the cross-model reducer still discards that invalid state; propagate costInvalid through day aggregation rather than passing only costUSD.
Useful? React with 👍 / 👎.
# Conflicts: # Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift
Summary
totalCents.totalCentszeroed the whole Cursor 30-day cost.Note